home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Library
/
RoseWare - Network Support Library.iso
/
apidev
/
batuti.arc
/
SETUSER.C
< prev
next >
Wrap
Text File
|
1990-01-11
|
2KB
|
65 lines
/*
*
* setuser -- sets the environment variable name in arg[1] to the actual
* login user name on ANW 2.1x
* Richard Connelly,(C) 1989,1990
*
*/
#include <stdio.h>
#include <conio.h>
#include <dos.h>
#include <mem.h>
#include <process.h>
#include <string.h>
#include "anw.h"
#include "mst_env.h"
void main(int argc, char *argv[])
{
int station; /* station */
CONNECTINFO who; /* connection information record */
/*
* Determine if the user is using the command correctly
*/
if (argc == 1)
{
fprintf(stderr," usage:\n\t setuser env-name \n");
exit(-1);
}
/*
*
* get connection information from anw
*
*/
station=GetConnectionNumber();
who=GetConnectInfo(station);
if (strlen(who.objectname)) /* there must be a login name */
{ /* if the user is logged in */
/* set the environment var passed */
if (m_putenv(argv[1],who.objectname))
{
fprintf(stderr,"Out of environment space\n");
}
exit(0); /* by argv & terminate successfully*/
}
else /* the user did not login */
{
fprintf(stderr,"Setuser v1.0\n");
fprintf(stderr,"\n\n\tYou have not logged into an Advanced Netware Server.\n");
fprintf(stderr,"\tLogin to the server an execute the command again or \n");
fprintf(stderr,"\tcontact the network system administrator for assistance. \n\n");
fprintf(stderr,"\t<< Press Any Key to Continue >>");
getch();
fprintf(stderr,"\n");
exit(-1); /* terminate with a failure code */
}
}